<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8"/>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="target-densitydpi=640,width=1280,user-scalable=yes">
    <base href="<?php echo $system['siteRoot'];?>" />
    <title>我的订单</title>
    <?php import_tpl("fragment/icon.php"); ?>
    <link rel="stylesheet" href="plugin/reset.css"/>
    <link rel="stylesheet" href="plugin/awesome4/css/font-awesome.min.css"/>
    <link rel="stylesheet" href="style/common.css"/>
    <link rel="stylesheet" href="style/my-order.css"/>
    <script src="plugin/jquery-1.11.2.min.js"></script>
    <script type="text/javascript">
    (function(){
        $(function(){
            //console.log( $('.slide .commodity'))
            $('.slide .order').addClass('menu-normal').removeClass('menu-label')    
        })
    })();
    </script>
    <script type="text/javascript">_root='<?php echo $system['siteRoot'];?>'</script>
    <script type="text/javascript"> var IS_IE9 = false;</script>
    <!-- 照顾低能浏览器 -->
    <!--[if lt IE 9]>
    <script type="text/javascript"> IS_IE9 = true; </script>
    <link rel="stylesheet" href="style/ie9-goods-comment.css"/>
    <![endif]-->
    <script src="script/api.js"></script>
    <script src="script/order-list.js"></script>
    <script>
        function refund() {
            return !!confirm("确定要退货/退款吗？");
        }
        function cancel(){
            return !!confirm("确定要取消订单吗？取消后将消失在列表中");
        }
    </script>
    
</head>
<body>
<div id="container" class="index">
    <?php import_part("custom.home","userBar"); ?>
    <?php import_part("custom.home","header"); ?>
    <?php import_tpl("fragment/nav.php"); ?>
    <div class="main-container">
        <div class="left">
            <?php import_tpl("fragment/mySlide.php"); ?>
            <div class="qr-code-box">
                <img src="images/weixin.png" alt="扫描二维码关注" title="关注我们的微信"/>
                <div>
                    <p class="weixin">扫描二维码</p>
                    <p class="concern">关注我们的微信</p>
                </div>
            </div>
        </div>
        <div class="right">
            <div class="my-order">
                <div class="myorder-bg">
                    <div class="myorder-title">
                        <p>我的订单</p>
                    </div>
                    <div class="order">
                        <table>
                            <tr>
                            <td class="cargo-img"></td>
                            <td class="cargo-name">商品名称</td>
                            <td class="cargo-price">单价</td>
                            <td class="cargo-amount">数量</td>
                            <td class="total-fee">实付款</td>
                            <td class="order-situation">交易状态</td>
                            <td class="order-operation">操作</td>
                            </tr>
                        </table>
                    </div>
                    <?php foreach ($r['list'] as $k=>$v) {?>

                        <table class="order-detail">
                            <tr class="order-brief">
                                <td class="order-time" colspan="6"><?= $v['create_time'] ?>  |  订单号：<?= $v['id'] ?>
                                    <span class="provider"><?= $v['company'] ?>&nbsp;联系电话：<?= $v['tel'] ?>&nbsp;QQ:<?= $v['qq'] ?></span>
                                </td>
                                <td class="order-operation">
                                    <a href="<?php e_page("order","detail",array('id'=>$v['id'])) ?>">查看订单</a>
                                    <?php if($v['state']=='unpaid'){ ?>
                                    <a href="<?php e_page("order","cancel",array('id'=>$v['id'])) ?>" onClick="return cancel()">删除订单</a>
                                    <?php }
                                      if($v['state']=='received'||$v['state']=='shipped_direct'){  ?>
                                          <a href="<?php e_page("orderAfter","addRefund",array('id'=>$v['id'],'type'=>0)) ?>" onClick="return refund()">退货</a>
                                      <?php }
                                      if($v['state']=='unshipped'||$v['state']=='unused'){?>
                                          <a href="<?php e_page("orderAfter","addRefund",array('id'=>$v['id'],'type'=>1)) ?>" onClick="return refund()">退款</a>
                                      <?php }?>
                                </td>
                            </tr>
                            <?php foreach ($v['goods'] as $k2=>$v2) {?>
                                <tr data-id="<?= $v['id']?>">
                                <td class="cargo-img"><a href="<?php e_page('goods','index',array('id'=>$v2['gopen_id'])) ?>"><img src="<?= $v2['thumb'] ?>" alt=""></a></td>
                                <td class="cargo-name"><a href="<?php e_page('goods','index',array('id'=>$v2['gopen_id'])) ?>"><?= $v2['name'] ?></a></td>
                                <td class="cargo-price"><p><?php if(!empty($v2['original_price'])){ echo '¥ '.$v2['original_price' ];}?></p>¥ <?= $v2['base_price' ] ?></td>
                                <td class="cargo-amount"><?= $v2['number' ] ?></td>
                                    <?php if($k2 == 0){
                                        $rowspan = count($v['goods']);
                                        if($v['type']=='normal'){
                                            switch($v['state']){
                                                case 'unpaid':$state='未付款';$iClass='fa fa-exclamation-circle';
                                                    $url='javascript:';$aValue='立即付款';break;
                                                case 'unshipped':$state='等待发货';$iClass='fa fa-truck';
                                                    $url=WebRouter::init()->getPage('my','sendShopMsg',array('user_id'=>$v['shop_id'],'order_id'=>$v['id']));$aValue='催一下发货';break;
                                                case 'shipped':$state='已发货';$iClass='fa fa-send';
                                                    $url='http://www.kuaidi100.com/chaxun?com='.$v['express_name'].'&nu='.$v['express_num'];$aValue='查看物流';break;
                                                case 'shipped_direct':$state='已发货';$iClass='fa fa-send';
                                                    $url='http://www.kuaidi100.com/chaxun?com='.$v['express_name'].'&nu='.$v['express_num'];$aValue='查看物流';
                                                    $url2=WebRouter::init()->getPage('orderAfter','confirm',array('id'=>$v['id']));$aValue2='确认收货';break;
                                                case 'service':$state='等待服务站配送';$iClass='fa fa-truck';
                                                    $url=WebRouter::init()->getPage('my','sendServiceMsg',array('user_id'=>$v['service_id'],'order_id'=>$v['id']));$aValue='催一下服务站';break;
                                                case 'received':$state='已签收';$iClass='fa fa-truck';
                                                    $url=WebRouter::init()->getPage('orderAfter','confirm',array('id'=>$v['id']));$aValue='确认收货';break;
                                                case 'confirmed':$state='已确认收货';$iClass='fa fa-check-circle';
                                                    $url=WebRouter::init()->getPage('orderAfter','comment',array('id'=>$v['id']));$aValue='开始评价';break;
                                                case 'refunding':$state='退款中';$iClass='fa fa-truck';
                                                    $url=WebRouter::init()->getPage('orderAfter','refund');$aValue='查看退货情况';break;
                                                case 'evaluate':$state='已评价';$iClass='fa fa-check-square-o';
                                                    $url=WebRouter::init()->getPage("order","detail",array('id'=>$v['id']));$aValue='查看评价';break;
                                                case 'assigned':$state='金额已分配完毕';$iClass='fa fa-truck';
                                                    $url='javascript:';$aValue='咨询客服';break;
                                                default :$state='不知道怎么了，请咨询客服';$iClass='fa fa-truck';
                                                    $url='javascript:';$aValue='unknown state';
                                            }
                                        }else{
                                            //service
                                            switch($v['state']){
                                                case 'unpaid':$state='未付款';$iClass='fa fa-exclamation-circle';
                                                    $url='javascript:';$aValue='立即付款';break;
                                                case 'unused':$state='未使用';$iClass='';
                                                    $url=WebRouter::init()->getPage('orderAfter','serviceCode',array('id'=>$v['id']));$aValue='获取验证码';break;
                                                case 'used':$state='已使用';$iClass='';
                                                    $url=WebRouter::init()->getPage('orderAfter','comment',array('id'=>$v['id']));
                                                    $aValue='评价订单';break;
                                                case 'refunding':$state='退款中';$iClass='fa fa-truck';
                                                    $url=WebRouter::init()->getPage('orderAfter','refund');$aValue='查看退款情况';break;
                                                case 'evaluate':$state='已评价';$iClass='fa fa-check-square-o';
                                                    $url=WebRouter::init()->getPage("order","detail",array('id'=>$v['id']));$aValue='查看评价';break;
                                                default :$state='不知道怎么了，请咨询客服';$iClass='fa fa-truck';
                                                    $url='javascript:';$aValue='unknown state';
                                            }
                                        }
                                        ?>
                                        <td class="total-fee" rowspan="<?=$rowspan ?>">¥ <span><?= $v['payment_amount' ] ?></span></td>
                                        <td class="order-situation" rowspan="<?=$rowspan ?>"><i class="<?=$iClass ?>"></i><?= $state ?></td>
                                        <td class="order-operation <?php if($r['currentId']==$v['id']) echo "current";?>" rowspan="<?=$rowspan ?>">
                                            <a href="<?= $url ?>" class="<?=$v['state']?>" <?php if($aValue=='查看物流'){echo "target='_blank'";} ?>><?= $aValue ?></a>
                                            <?php if(isset($url2)){ ?>
                                            <a href="<?= $url2 ?>" class="<?=$v['state']?>"><?= $aValue2 ?></a>
                                            <?php } ?>
                                        </td>
                                    <?php }?>
                                </tr>
                            <?php } ?>
                        </table>
                    <?php }?>
                </div>
                <?php if($r['page'] instanceof Page && !$r['pageEmpty']){
                $page=$r['page'];?>
                <div class="turn-page">
                    <?php if($page->ifPrev()) { ?>
                        <a href="<?=$page->getPageUrl($page->getPrev());?>"><i class="fa fa-chevron-left"></i>上一页</a>
                    <?php }?>
                    <?php foreach($page->getPageArray() as $i){ ?>
                        <a href="<?=$page->getPageUrl($i);?>"><?php echo $i;?></a>
                    <?php } ?>
                    <?php if($page->ifNext()) { ?>
                        <a href="<?=$page->getPageUrl($page->getNext());?>">下一页<i class="fa fa-chevron-right"></i></a>
                    <?php }?>
                </div>
                <?php }?>
            </div>
        </div>
    </div>
    <?php import_tpl("fragment/footer.php"); ?>
</div>
<div class="alert-bg order-pay">
    <div class="alert-box">
        <form id="order-pay" action="<?php e_page('order','pay') ?>" method="get">
            <input type="hidden" id="order-id" name="order_id" value="">
            <div class="alert-box-title">选择支付方式<a class="close" href="javascript:"><i class="fa fa-close"></i></a></div>
            <div class="pay-way">
                <p><input type="radio" id="pay-way-money" name="pay_way" value="money" checked>
                    <label for="pay-way-money" id="pay-way-money-label">余额支付&nbsp;&nbsp;&nbsp;&nbsp;<span>(账户余额元，余额支付元，其余元使用支付宝)</span></label></p>
                <div class="rest-pay-captcha">
                    <label for="test-code">验证码</label>
                    <input name="code" type="text" id="test-code" placeholder="请输入验证码">
                    <i class="fa fa-check-circle code-right" style="display:none;"></i><i class="fa fa-times-circle code-wrong" style="color:red;"></i>
                    <a href="javascript:" class="getCodeButton">免费获取验证码</a>
                </div>
                <input type="radio" id="alipay"  name="pay_way" value="alipay">
                <label for="alipay">
                    <img src="images/Pay.png" alt="">
                </label>
            </div>
            <a href="javascript:" class="info-affirm">确认</a>
        </form>
    </div>
</div>
</body>
</html>